﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TERP.Constants;

namespace TERP.WaterClient.Common
{
    public class SystemConfig
    {
        public enum AppClient { DesktopHtc,DesktopDealer };
        //
        public string GwUserCode { private set; get; }
        public string GwPassword { private set; get; }
        public string PartnerCode { private set; get; }
        //
        public string WsUrl { set; get; }
        public string SystemLanguage { private set; get; }
		public bool AuthenticateOn { private set; get; }

        //
        public void LoadConfig(AppClient appClient){
            this.GwUserCode = CommonUtils.Registry.GetKey("HKEY_CURRENT_USER\\Software\\ITS\\ERP.ServiceMng", "MainGwUserCode", "ITS").ToString();
            this.GwPassword = CommonUtils.Registry.GetKey("HKEY_CURRENT_USER\\Software\\ITS\\ERP.ServiceMng", "MainGwUserPassword", "ITS").ToString(); ;

			//~!@#$%^&*() Thay doi khi build deploy
			this.AuthenticateOn = false;
            switch (appClient){
                case AppClient.DesktopHtc:
                    this.PartnerCode = SysPartner.DesktopAppHTC;
                    break;
                case AppClient.DesktopDealer:
                    this.PartnerCode = SysPartner.DesktopAppDealer;
                    break;
                default:
                    this.PartnerCode = SysPartner.DesktopAppHTC;
                    break;
            }
            this.SystemLanguage = Language.en_US;
            //
            this.WsUrl = Properties.Settings.Default.WsUrl.Trim();
        }

        public void SaveConfig(){
            Properties.Settings.Default.WsUrl = this.WsUrl;
            Properties.Settings.Default.Save();
        }

        private static SystemConfig instance;
        public static SystemConfig Instance{
            get {
                if (instance == null)
                    instance = new SystemConfig();
                return instance;
            }
        }

        private SystemConfig(){}
    }
}
